let logger = require('./logUtil');
const ServerError = require('./ServerError');

let util = {};

util.code = ServerError.CODE;

util.ServerError = ServerError;

util.logError = (ctx,error,msg) => {
    error.message = error.message || msg;
    logger.logError(ctx,error);
}


util.getLoginUid = (ctx) => {
    if(ctx.session && ctx.session.loginUser){
        return ctx.session.loginUser.id || 0;
    }
    return 0;
}

module.exports = util;



